//
//  TZPreviewController.m
//  DemoProduct
//
//  Created by ttouch on 16/7/13.
//  Copyright © 2016年 周毅莹. All rights reserved.
//

#import "TZPreviewController.h"

@interface TZPreviewController ()<QLPreviewControllerDataSource>

@end

@implementation TZPreviewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_clicked"] style:UIBarButtonItemStyleDone target:self action:@selector(back)];
    self.dataSource = self;
    self.delegate = self;
    
}

- (void)back {
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark QLPreviewControllerDelegate

- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller{
    return 1;
}

- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index{
    NSString *filePath = [[NSBundle mainBundle] pathForResource:self.filename ofType:nil];
    return [NSURL fileURLWithPath:filePath isDirectory:NO];
}

@end
